home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 7
/
FM Towns Free Software Collection 7.iso
/
t_os
/
tacop
/
eupbug.c
< prev
next >
Wrap
Text File
|
1993-11-30
|
3KB
|
128 lines
/*
EUPドライバを終了処理を全て削除し動作させる
compile usage : run386 hcd386p eupbug
link usage : run386 tlinkp eupbug -lib hce snd tbios -tc -s 77824
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <snd.h>
#include <mos.h>
int eup_load();
char swork[16384];
char mwork[MosWorkSize];
char *eup_buf;
int flen,signature;
FILE *fp;
int main(int argc, char *argv[])
{
int ret,tr,x,y;
if (argc < 2){
printf("usage:RUN386 EUPBUG <EUP filename>\n");
return(1);
}
SND_init(swork);
MOS_start(mwork,MosWorkSize);
SND_elevol_set(0,127,127);
SND_elevol_mute(0x0f);
SND_eup_init();
// SND_rs_midi_init();
if((fp = fopen(argv[1],"rb")) == NULL){
ret = 1;
goto err_end;
}
ret = eup_load();
fclose(fp);
if (!ret){
SND_eup_play_start(eup_buf,flen,signature);
do {
MOS_rdpos(&tr,&x,&y);
} while(SND_eup_stat_flag() && (tr != 0x03));
// SND_eup_play_stop();
// free(eup_buf);
}
err_end:
// SND_rs_midi_end();
// SND_eup_end();
// MOS_end();
// SND_end();
return(ret);
}
int eup_load()
{
int i,j,size,tempo;
char buffer[160];
char bankpath[128];
char fm_bankname[16];
char pcm_bankname[16];
fseek(fp,0,SEEK_END);
flen = (unsigned int)ftell(fp);
fseek(fp,0,SEEK_SET);
if (flen <= 2048+4+1+1)
return(1);
fseek(fp,852,SEEK_SET);
fread(buffer,1,160,fp);
for(i=0 ; i<32 ;i++){
SND_eup_mute_set(i,(int)buffer[i]);
SND_eup_port_set(i,(int)buffer[32+i]);
SND_eup_midi_ch_set(i,(int)buffer[64+i]);
SND_eup_bias_set(i,(int)buffer[96+i]);
SND_eup_transpose_set(i,(int)buffer[128+i]);
}
fseek(fp,1748,SEEK_SET);
fread(buffer,1,6,fp);
for(i = 0;i < 6;i++)
SND_midi_ch_assign(i,(int)buffer[i]);
fread(buffer,1,8,fp);
for(i = 0;i < 8;i++)
SND_midi_ch_assign(i+64,(int)buffer[i]);
memset(bankpath,0,128);
fread(&bankpath[0],1,8,fp);
if(bankpath[0] != '\0'){
for(j= 0;bankpath[j] != '\0';j++);
bankpath[j+0] = '.';
bankpath[j+1] = 'f';
bankpath[j+2] = 'm';
bankpath[j+3] = 'b';
bankpath[j+4] = '\0';
SND_fm_bank_load(bankpath,fm_bankname);
}
memset(bankpath,0,128);
fread(&bankpath[0],1,8,fp);
if(bankpath[0] != '\0'){
for(j= 0;bankpath[j] != '\0';j++);
bankpath[j+0] = '.';
bankpath[j+1] = 'p';
bankpath[j+2] = 'm';
bankpath[j+3] = 'b';
bankpath[j+4] = '\0';
SND_pcm_bank_load(bankpath,pcm_bankname);
}
fseek(fp,2048,SEEK_SET);
fread(&size,4,1,fp);
fread(buffer,1,2,fp);
signature = (int)buffer[0];
tempo = (int)buffer[1];
SND_eup_tempo_set(tempo);
flen -= 2048+4+1+1;
if ((eup_buf = malloc(flen)) == 0)
return(1);
fread(eup_buf,1,flen,fp);
return(0);
}